<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2016/3/5 0005
  Time: 下午 3:17
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>网上书店注册</title>
    <link rel="stylesheet" type="text/css" href="../../resources/css/login.css"/>
    <script type="text/javascript" src="../../resources/js/jquery.js"></script>
    <style type="text/css">
        .tip {
            visibility: hidden;
        }

        span {
            color: red;
        }
    </style>
    <script type="text/javascript">
        $(document).ready(function () {
            //把提示隐藏
            $("span").addClass("tip");

            $("#username").blur(function () {
                var username = $("#username").val();
                $.ajax({
                    type: "post",
                    url: "/register/checkUsername.html",
                    data: {
                        username: username
                    },
                    success: function (data) {
//                        alert("data = " + data);
                        if ("ERROR" == data) {
                            alert(data);
                            $("#usernameTip").removeClass("tip");
                        } else {
                            $("#usernameTip").addClass("tip");
                        }
                    }
                });
            });

            $("#ensurePwd").blur(function () {
                var ensurePwd = $(this).val();
                var password = $("#password").val();
//                alert("ensurePwd = " + ensurePwd + "," + password);
                var pwdTip = $("#pwdTip");
                if (ensurePwd !== password) {
                    //显示提示
                    pwdTip.removeClass("tip");
                } else {
                    pwdTip.addClass("tip");
                }
            });
        });
    </script>
</head>
<body>
<div class="title">网上书店注册</div>
<div class="login">
    <form id="loginForm" action="/register/registering.html" method="POST">
        <table>
            <tr>
                <th>用户名:</th>
                <td>
                    <input id="username" type="text" name="username">
                    <span id="usernameTip">
                        用户名已被注册！
                    </span>
                </td>
                <td>&nbsp;</td>
            </tr>

            <tr>
                <th>密码:</th>
                <td>
                    <input id="password" type="password" name="password">
                </td>
                <th>&nbsp;</th>
            </tr>
            <tr>
                <th>请确认密码:</th>
                <td>
                    <input id="ensurePwd" type="password" name="password">
                    <span id="pwdTip">
                        两次输入密码不一致
                    </span>
                </td>
                <th>&nbsp;</th>
            </tr>
            <tr>
                <th>
                </th>
                <td>
                    <input type="submit" value="注册" class="loginButton">
                    <span>&nbsp;</span>
                    <input class="loginButton" type="reset" value="重置"/>
                </td>
                <td>
                </td>
            </tr>
        </table>
    </form>
</div>
</body>
</html>
